package com.example.demo.aop.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.demo.aop.service.ICouponService;

import java.util.HashMap;
import java.util.Map;

@Service
public class CouponServiceImpl implements ICouponService {

    @Autowired
    ICouponService couponService;

    @Override
    public void deposit() {
        System.out.println("Coupon depositing ...");
//        couponService.pay();
        Map<String, Object> ret = couponService.pay("abc", 23);
        System.out.println("deposit pay ret: ["+ret.get("code")+","+ret.get("msg")+"]");
    }

    @Override
    public void pay() {
        System.out.println("Pay with webchat pay ...");
        try {
            Thread.sleep(2000l);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Override
    public Map<String, Object> pay(String str, Integer num) {
        System.out.println("Pay with webchat pay ... ["+ str + "," + num + "]");
        try {
            Thread.sleep(1000l);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Map<String, Object> ret = new HashMap<>();
        ret.put("code", 0);
        ret.put("msg", "ok");
        return ret;
    }
}
